package com.yeban.javase.review.exercise;

import java.io.*;

/**
 * @Desc TODO
 * @Author yeban
 * @Date 2025/10/27
 */
public class BufferedReaderRRReview {

    public static void main(String[] args) {
        try(
                FileReader fr = new FileReader("src/com/yeban/javase/review/text/poem");
                FileWriter fw = new FileWriter("src/com/yeban/javase/review/text/poem_copy");

                BufferedReader br = new BufferedReader(fr);
                BufferedWriter bw = new BufferedWriter(fw);

                BufferedReader br1 = new BufferedReader(new FileReader("src/com/yeban/javase/review/text/poem"));
                BufferedWriter bw1 = new BufferedWriter(new FileWriter("src/com/yeban/javase/review/text/poem_copy"));

                /*
                错误传参
                BufferedReader br2 = new BufferedReader("src/com/yeban/javase/review/text/poem");
                BufferedWriter bw2 = new BufferedWriter("src/com/yeban/javase/review/text/poem_copy");

                BufferedReader br3 = new BufferedReader(new File("src/com/yeban/javase/review/text/poem"));
                BufferedWriter bw3 = new BufferedWriter(new File("src/com/yeban/javase/review/text/poem_copy"));
                */
        ) {
            char[] chars = new char[1024];
            int len;
            while((len = br.read(chars)) != -1) {
                bw.write(chars, 0, len);
            }
            System.out.println("写入成功！");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
